<html>
<head><meta charset="utf-8"><title>Defining rustc&#x27;s cfg in build.rs · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Defining.20rustc&#x27;s.20cfg.20in.20build.2Ers.html">Defining rustc&#x27;s cfg in build.rs</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209313717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Defining%20rustc%27s%20cfg%20in%20build.rs/near/209313717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kchibisov <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Defining.20rustc&#x27;s.20cfg.20in.20build.2Ers.html#209313717">(Sep 07 2020 at 16:53)</a>:</h4>
<p>I'm trying to understand whether there's a way to pass flags from <a href="http://build.rs">build.rs</a> to rustc.</p>
<p>The need for that is the following:</p>
<p>Assume that you have some crate without any features for the end users. However you're using system library and you use some functions from newer versions of it, which couldn't be available on the target platform. So the thing you usually do in such cases is that you try to compile some code with that library and set a 'feature'(you may pass random cfg though, feature isn't really required) if it compiles fine, and then you properly handle missing things in your code.</p>
<p>Also, I don't want to completely redefine cfg, that cargo will be passing to rustc, just append to it.</p>
<p>If there's a known way to do that?</p>



<a name="209313927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Defining%20rustc%27s%20cfg%20in%20build.rs/near/209313927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Defining.20rustc&#x27;s.20cfg.20in.20build.2Ers.html#209313927">(Sep 07 2020 at 16:55)</a>:</h4>
<p>are you looking for <a href="https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-cfgkeyvalue">https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-cfgkeyvalue</a></p>



<a name="209314294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Defining%20rustc%27s%20cfg%20in%20build.rs/near/209314294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kchibisov <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Defining.20rustc&#x27;s.20cfg.20in.20build.2Ers.html#209314294">(Sep 07 2020 at 16:59)</a>:</h4>
<p>yeah, that's was it. thx.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>